package com.csgsystems.im.survey.persistence.hibernate;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;

import com.csgsystems.im.hibernate.HibernateDao;
import com.csgsystems.im.survey.Question;
import com.csgsystems.im.survey.persistence.QuestionDao;

public class QuestionDaoImpl extends HibernateDao<Question, Question.QuestionKey> implements QuestionDao {

	@Override
	public List<Question> findBySurveyId(Long id) {
		Session session = sessionFactory.getCurrentSession();
		Query query =  session.createQuery("from Question q " +
				"where q.id.surveyId = :surveyId " +
				"order by q.id.surveyId, q.id.questionId, q.id.languageId");
		query.setLong("surveyId", id);
		return query.list();
		
	}

}
